<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button onclick="setItem()">设置数据</button>
<button onclick="removeItem()">删除数据</button>
<button onclick="getItem()">获取数据</button>
</body>
<script>
    //体会会话级和持久级数据存储
    function setItem() {
        //给浏览器设置会话级的数据
        window.sessionStorage.setItem("sessionMsg", "zhangsan")
        //设置持久级的数据
        window.localStorage.setItem("localMsg", "lisi")
        console.log("haha")
    }

    //删除数据
    function removeItem() {
        window.localStorage.removeItem("localMsg")
        window.sessionStorage.removeItem("sessionMsg")
    }

    //获取数据
    function getItem() {
        console.log(window.localStorage.getItem("localMsg"))
        console.log(window.sessionStorage.getItem("sessionMsg"))
    }
</script>
</html>